//index.js
//获取应用实例
const app = getApp();
Page({
    data: {
		imgBaseUrl: '',
		productBaseUrl: '',
    	banners: [],
		brands: [],
		products: [],
		indicatorDots: true,
		autoplay: true,
		interval: 3000,
		duration: 1000
    },
	bindNavToCategory: function (e) {
		wx.switchTab({
			url: "../category/index"
		});
		app.brandId = e.currentTarget.dataset.brandId;
		app.curTitle = e.currentTarget.dataset.curTitle;
	},
    onLoad: function (e) {
		wx.showNavigationBarLoading();
		this.setData({
			imgBaseUrl: app.globalData.imgBaseUrl,
			productBaseUrl: app.globalData.productBaseUrl
		})
        var that = this;
        wx.request({
            url: 'http://192.168.1.199:3389/v3/banners',
            success: function (res) {
                that.setData({
					banners: res.data
                })
            }
        });
		wx.request({
			url: 'http://192.168.1.199:3389/Category',
			data: {type: 'brand'},
			success: function (res) {
				that.setData({
					brands: res.data
				})
			}
		});
		wx.request({
			url: 'http://192.168.1.199:3389/product/list',
			success: function (res) {
				that.setData({
					products: res.data
				})
			}
		})
		wx.hideNavigationBarLoading();
    },
	onHide: function() {
		console.log('onHide')
    },

	onLaunch: function () {
        console.log('onlaunch')
	},
	onShow: function() {
		// wx.showNavigationBarLoading();
		wx.setNavigationBarTitle({
			title: 'Home'
		});
    },

	onUnlaunch: function() {
		console.log('onUnlaunch')
    },

	userInfoReadyCallback: function() {
		console.log('userInfoReadyCallback')
    }
})
